Skip to content

tool-packaging: soffice through the exec runner, soffice_memory, SVG through rsvg-convert (v0.12.0) - #50

Merged
JaimeStill merged 6 commits into
mainfrom
tool-packaging
Nov 29, 2026
Merged

JaimeStill merged 6 commits into
mainfrom
tool-packaging

Conversation

@JaimeStill

Copy link
Copy Markdown
Contributor

capstone.data-intelligence.bunrei · task 16/17 · tool-packaging

Summary

  • Bunrei has a service image: a root Dockerfile on debian:13.8-slim, which holds every tool
    docproc's routes run. It runs as uid 10001 with one work volume, which is also TMPDIR.
  • Every tool runs through docproc's exec runner, soffice included, so no docker socket is needed.
    soffice runs under its own 8 GiB bound (soffice_memory), and every other tool keeps 2 GiB.
  • SVG renders through rsvg-convert, never magick, so an SVG's file and URL references are
    never followed.
  • Startup refuses any route that isn't wired and isn't in jobs.exclude, naming each route with
    its reason.
  • New tier mise run image and a CI job: every route is wired, one input per route completes,
    and a hostile SVG renders blank. The integration tier now proves checkpoint resume on an mbox.
  • docproc v0.12.0 releases LibreOfficeExec, LibreOfficeMemory/soffice_memory, and
    rsvg-convert.

Core changes

  1. docproc stages.Options: soffice can run on the host. Why: an image without a docker
    socket otherwise loses the office and vision-converted routes.
    LibreOfficeExec   bool  // soffice from PATH through the exec runner
    LibreOfficeMemory int64 // its own RLIMIT_AS; settings key soffice_memory, unset = tool_memory
  2. docproc SVG → rsvg-convert (minimum 2.58). Why: Debian's ImageMagick has no librsvg, and
    its own renderer follows <image href> to local files and URLs.
  3. Bunrei startup: every route not excluded is required. Why: a missing tool is a packaging
    fault, not a quiet per-part failure.
  4. The image and its pins: Debian packages, LibreOffice 26.8.3 pinned from trixie-backports
    (it and liborcus only), ffmpeg 9.1 from mwader/static-ffmpeg, 7zz 26.06, and docproc-ooxml,
    docproc-mail, and docproc-onenote by tag, each checked against its release's SHA256SUMS.
    Currency and upgrade read every FROM, COPY --from, and ARG pin.
  5. Tests: the image tier (-tags image), and a killed-replica mbox job that resumes from its
    checkpoint (docproc-mail pinned through mise).

Verify

mise run check: ✓ docproc and Bunrei. mise run currency: ✓ clean. mise run integration: ✓.
mise run image: ✓ 14 subtests.

  1. mise run image:build, then docker run --rm --entrypoint id capstone-bunrei:local →
    uid=10001(bunrei).
  2. Run the image on the host network against the compose stack, with the BUNREI_* variables
    and AI_GATEWAY_TOKEN set, then docker logs → one tool row per program, each at or above
    its minimum (soffice from=/usr/bin/soffice), and all ten routes state=wired.
  3. Run it again with -e PATH=/usr/bin:/bin → it exits 1 with "required routes missing, each to
    be provided or named in jobs.exclude: office (docproc-ooxml: not found); …".
  4. Add -e BUNREI_JOBS_EXCLUDE=office,nested,onenote,archive,audio,video → it starts, those
    routes log state=excluded, and /healthz returns 200.
  5. Start with a stale file in the work volume → after startup the volume is empty.
  6. Submit a .docx, a .heic, and an SVG whose <image href> names /app/config.json → each job
    reaches completed, and the SVG's picture is plain white. (Followed through the image tier's
    stand-in gateway, not the real one.)
  7. docker buildx build --platform linux/arm64 … → the server and tools are arm64.

Decided without you

  1. soffice_memory is an optional docproc settings key; unset, it takes tool_memory's value.
    cmd/docproc doesn't read it, because it runs soffice in its container.
  2. The office route requires rsvg-convert too, because it shares picture's converter. The office
    and picture stage identities change in v0.12.0, so cached docproc results for them miss once.
  3. Upgraded go-messaging and go-messaging/nats to v0.8.0, an additive release that came out
    during the task and was failing currency.
  4. The image tier lives in integration/ under the image tag, so it shares the harness and
    stand-in gateway, and it needs a fresh stack (mise run image always starts one).
  5. 7zz is not checksum-verified: 7-Zip publishes no checksum file.
  6. To keep the README under its 1,500-word budget, its graph-tests paragraph moved to
    docs/building-out.md, and the compose README is renamed "The test stack".
  7. Dropped decision "jobs: startup requires no docproc route", replaced by the required-routes
    decision. Trimmed the jobs: checkpoint decision to its cache-replay part. Dropped
    "tool-packaging: TMPDIR is work_dir" and the integration-tier checkpoint decision, because the
    docs and tests now state them.
  8. Informational: in the image, Debian's soffice also converted under 2 GiB. The 8 GiB rests on
    the host's 4 GiB failure.

Redirects and escalations

  1. Escalation, slice 1: soffice fails under a 4 GiB RLIMIT_AS. Should it get its own bound, set to
    8 GiB in Bunrei, with 2 GiB kept for every other tool? Answer: yes.
  2. Escalation, slice 4: Debian's ImageMagick lacks librsvg, so SVG fell back to MSVG. Should
    docproc render SVG with rsvg-convert, and the image install librsvg2-bin? Answer: yes.

Merge danger: one-way door: docproc's v0.12.0 tag reaches the module proxy (Release:
docproc v0.12.0). Everything else is two-way: the image is built, not published. Blast radius:
docproc and Bunrei. docproc merges first and waits on CI (checks, then ci), then the tag. Bunrei
then drops its temporary replace, its COPY --from=docproc line, and --build-context,
requires v0.12.0, and merges once its checks pass. Its CI image job, on push to main, is the
first to run the image without the temporary build context.

Needs you: none

…ns soffice through the exec runner

- stages.Options.LibreOfficeExec: set, Build looks up soffice on PATH and builds it with
  tool.NewExec under the same Memory, Timeout, and Env as every other exec-run tool; docker is
  never looked up for it, and soffice's Set.Tools row names its path. False, the zero value, keeps
  soffice in picture.LibreOfficeImage through the container runner. cmd/docproc is unchanged.
- Unit tier: TestBuildLibreOfficeExec, over the tooltest stand-ins, records the lookups: soffice
  and never docker when set, docker and never soffice when unset, office and vision-converted
  wired or missing accordingly.
- Integration tier: TestLibreOfficeExec builds the office route with the option through
  exec.LookPath, fails on a docker lookup, and prepares office/test/testdata/rtf/memo.rtf through
  the host's soffice.
- README: the setting, and the correction that Build runs ffmpeg and ffprobe through the exec
  runner alone; the go get line names v0.12.0. docs/api.md lists the field. CHANGELOG: Unreleased
  becomes [v0.12.0] - 2026-11-29 with the setting under Added, an empty Unreleased above, and the
  compare links extended, as b2ccbba did. Not tagged.

Decisions:
- The option is a bool named for the program's package spec (LibreOfficeSpec/LibreOfficeImage)
  rather than a general per-tool runner choice: soffice is the only tool Build runs in a
  container, so nothing else needs one.
- The integration test sets no memory bound: on this host soffice 26.8.1 fails to write its
  output under a 4 GiB RLIMIT_AS and succeeds under 8 GiB, so a bound in the test would hold a
  host-specific floor.

mise run check passes.
…iceMemory bounds soffice run through the exec runner

- stages.Options.LibreOfficeMemory: with LibreOfficeExec set, soffice's tool.Spec.MemoryLimit (its
  RLIMIT_AS through prlimit) in place of Memory; every other tool keeps Memory. No library default:
  zero is none, as Memory's zero is, and Build refuses one below zero through ErrRequest. With
  LibreOfficeExec unset, soffice stays under Memory in the container, as before.
- The office and picture stages' configs carry LibreOfficeMemory beside Memory, and a part failure
  whose ExitError is soffice's names soffice's bound ("soffice: killed by SIGABRT under a 16 GiB
  memory bound"); other tools' failures keep naming Memory.
- Unit tier: TestBuildLibreOfficeExec gains a case with Memory 8 GiB and LibreOfficeMemory 16 GiB,
  whose stand-in magick and soffice refuse their version commands unless their RLIMIT_AS is their
  own bound (PictureSettings.Limit, new SofficeSettings.Limit). TestLibreOfficeMemoryReason kills
  a stand-in soffice converting an EMF and reads the 16 GiB bound in the reason. TestBuildRefuses
  covers a negative soffice bound. Each fails with the soffice bound routed as Memory.
- Integration tier: TestLibreOfficeExec runs with Memory 2 GiB and LibreOfficeMemory 8 GiB and
  prepares memo.rtf; at 4 GiB it fails, as measured.
- README's memory-bound section, docs/api.md's Options, and the v0.12.0 CHANGELOG entry describe
  the bound.

Decisions:
- A sibling field, LibreOfficeMemory, beside the LibreOfficeExec bool rather than a struct: one
  added field, the bool from slice 1 kept, and the pair reads as one setting by name.
- A nonzero LibreOfficeMemory with LibreOfficeExec unset is ignored, not refused: the container
  path's behavior stays unchanged, and the field documents it bounds soffice only through the exec
  runner.
- The stage adapters pick soffice's bound by the ExitError's program name, one unexported helper
  (runMemory), rather than changing Classify's signature for every stage.

mise run check passes.
…bles into stages.Options.LibreOfficeMemory

settings gains the optional key soffice_memory (Settings.SofficeMemory), whole bytes, zero or
more, assembled into stages.Options.LibreOfficeMemory. Unset, it assembles to tool_memory's value,
so soffice keeps the bound the host already chose; below zero it is refused by name as a KeyError.

Decisions:
- cmd/docproc reads each DOCPROC_ variable through its own readEnv line, not generically, and runs
  soffice in its container (LibreOfficeExec unset), so the key would be inert there. cmd/docproc
  gains no DOCPROC_SOFFICE_MEMORY; settings/doc.go, docs/api.md, and docs/packages.md say
  soffice_memory is the one key it doesn't read.
- Run.Stages' doc names LibreOfficeExec among the options left to the host.
- cmd/docproc's checked build requires docproc v0.11.0, so its bounds tests are unchanged; once it
  requires v0.12.0, its expected starting Run carries LibreOfficeMemory equal to Memory.

mise run check passes.
…g-convert, never magick

picture renders an SVG through librsvg's own command, rsvg-convert, in place of magick's rsvg:
coder, which a magick built without librsvg (Debian 13's 7.1.1-43) reads through ImageMagick's MSVG
renderer, following <image href> to local files and URLs. The run is --zoom=<density/96>
--background-color=white --format=png --output=<png> <copy>: zoom scales CSS pixels exactly as
magick's -density did (pixel-identical on shapes.svg, and physical units stay true), the output is
opaque RGB on white, and librsvg writes no time chunk, so it is reproducible with no magick step.

picture.RsvgConvertSpec and RsvgConvertMinimum (2.58) declare the tool; picture.Config.RsvgConvert
is required and version-checked through Tool.AtLeast in NewConverter. stages.Build builds it
through the exec runner, as magick, and the office and vision-converted routes require it, their
rows carrying its version line last.

Decisions:
- Minimum 2.58: Ubuntu 24.04 LTS's, the rule LibreOfficeMinimum follows, and after 2.56.3's fix of
  CVE-2023-38633 (path traversal through an SVG reference). Debian 13's 2.60.0 passes; the flags
  used are far older.
- Config.RsvgConvert is required rather than optional, so the office route, whose converter is the
  same picture.Converter, requires rsvg-convert too though it hands SVGs on as stored. An optional
  field would have needed a refusal of its own; ErrNoReader names magick.
- rsvg-convert works in the batch's picture-* directory (its HOME under the exec runner), since
  fontconfig writes its cache under HOME and the caller's directory must hold the PNG alone.
- rsvg-convert rounds a fractional size up where magick rounded down (ink.svg 237x119, was 236x118;
  script-bearing.svg 625x188, was 625x187); the integration expectations follow.
- magick's Limits no longer bound SVG rendering; the Tool's memory bound and timeout do, and
  --unlimited is never passed. TestLimitsHost now proves the width limit on a TIFF.
- The office and picture stage identities change through their Version lines; the v0.12.0
  CHANGELOG says so.
- CI installs no magick (the tools tier runs on the developer's machine), so docs/development.md's
  host prerequisites gain rsvg-convert and no workflow changes. cmd/docproc's module stays on
  v0.11.0 and is unchanged; once it requires v0.12.0 it finds rsvg-convert through exec.LookPath as
  it finds magick, and docs/command.md's unit-timeout list will need it then.

mise run check passes; go test -tags integration over picture, office, and stages passes,
including the hostile SVG (an absolute path, a file:// URL, and an http URL render nothing and
open no connection).
… wrapped to the package's width

Comments (architecture/principles/comments.md): the doc comments of
picture.NewConverter, ConvertPages, and ConvertBatch, settings' package doc, and
Settings.Assemble, which the task's edits left overrunning the 100-column wrap
or broken mid-paragraph, rewrapped without a change of wording.
@JaimeStill
JaimeStill merged commit e55e678 into main Nov 29, 2026
8 checks passed
@JaimeStill
JaimeStill deleted the tool-packaging branch November 29, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant